package leetcode_core.leetcode_5;

import org.junit.Test;

/**
 * 功能描述
 *
 * @author: 张庭杰
 * @date: 2023年01月07日 10:54
 */
public class FindProphet {
    public int findProphet(int n, int[][] trust) {
        if(trust.length == 0){
            return -1;
        }
        int[] count = new int[n+1];
        for (int[] ints : trust) {
            int t = ints[1];
            count[t]++;
            if (count[t] == n-1) {
                return t;
            }
        }
        return -1;
    }
    @Test
    public void test(){
        System.out.println(findProphet(2, new int[][]{{1, 2}}));
    }
}
